/**
 * Copyright JS Foundation and other contributors, http://js.foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/

.button {
    @include disable-selection;
}

#red-ui-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--red-ui-header-height);
    background: var(--red-ui-header-background);
    box-sizing: border-box;
    padding: 0px 0px 0px 20px;
    color: var(--red-ui-header-menu-color);
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--red-ui-header-accent);
    padding-top: 2px;

    span.red-ui-header-logo {
        float: left;
        font-size: 30px;
        line-height: 30px;
        text-decoration: none;
        white-space: nowrap;

        span {
            vertical-align: middle;
            font-size: 16px !important;
            &:not(:first-child) {
                margin-left: 8px;
            }
        }
        img {
            height: 18px;
        }

        a {
            color: inherit;
            &:hover {
                text-decoration: none;
            }
        }

    }

    .red-ui-header-toolbar {
        display: flex;
        align-items: stretch;
        padding: 0;
        margin: 0;
        list-style: none;
        float: right;

        > li {
            display: inline-flex;
            align-items: stretch;
            padding: 0;
            margin: 0;
            position: relative;
        }
    }

    .button {
        height: 100%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 20px;
        text-align: center;
        font-size: 20px;
        padding: 0px 12px;
        text-decoration: none;
        color: var(--red-ui-header-menu-color);
        margin: auto 5px;
        vertical-align: middle;
        border-left: 2px solid var(--red-ui-header-background);
        border-right: 2px solid var(--red-ui-header-background);

        &:hover {
            border-color: var(--red-ui-header-menu-item-hover);
        }
        &:active, &.active {
            background: var(--red-ui-header-button-background-active);
        }
        &:focus {
            outline: none;
        }
    }

    .button-group {
        display: inline-block;
        margin: auto 15px;
        vertical-align: middle;
        clear: both;
        & > a {
            display: inline-block;
            position: relative;
            float: left;
            line-height: 22px;
            font-size: 14px;
            text-decoration: none;
            padding: 4px 8px;
            margin: 0;
        }
    }

    .red-ui-deploy-button {
        background: var(--red-ui-deploy-button-background);
        color: var(--red-ui-deploy-button-color);

        &:hover {
            background: var(--red-ui-deploy-button-background-hover);
        }
        &:focus {
            outline: none;
        }
        &:active {
            background: var(--red-ui-deploy-button-background-active);
            color: var(--red-ui-deploy-button-color-active);
        }
    }

    .red-ui-deploy-button-spinner {
        position: absolute;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        text-align: center;

        img {
            opacity: 0.8;
            height: 100%;
        }
    }

    #red-ui-header-button-deploy {
        padding: 4px 12px;
        &.disabled {
            cursor: default;
            background: var(--red-ui-deploy-button-background-disabled);
            color: var(--red-ui-deploy-button-color-disabled);

            .red-ui-deploy-button-content>img {
                opacity: 0.3;
            }
            &+ #red-ui-header-button-deploy-options {
                background: var(--red-ui-deploy-button-background-disabled);
                color: var(--red-ui-deploy-button-color-active);
            }
            &+ #red-ui-header-button-deploy-options:hover {
                background: var(--red-ui-deploy-button-background-disabled-hover);
            }
            &+ #red-ui-header-button-deploy-options:active {
                background: var(--red-ui-deploy-button-background-disabled);
            }
        }

        .red-ui-deploy-button-content>img {
            margin-right: 8px;
        }
    }

    .red-ui-deploy-button-group.open {
        #red-ui-header-button-deploy-options {
            background: var(--red-ui-header-button-background-active) !important;
        }
    }

    .red-ui-deploy-button-group.readOnly {
        .fa-caret-down { display: none; }
        .fa-lock { display: inline-block; }
    }
    .red-ui-deploy-button-group:not(.readOnly) {
        .fa-caret-down { display: inline-block; }
        .fa-lock { display: none; }
    }
    .red-ui-deploy-button-group.readOnly {
        a {
            pointer-events: none;
        }
    }

    li.open .button {
        background: var(--red-ui-header-button-background-active);
        border-color: var(--red-ui-header-button-background-active);
    }


    ul.red-ui-menu-dropdown {
        background: var(--red-ui-header-menu-background);
        border: 1px solid var(--red-ui-header-menu-background);
        width: 260px !important;
        margin-top: 0;
        li a {
            color: var(--red-ui-header-menu-color);
            padding: 3px 10px 3px 30px;
            img {
                max-width: 100%;
                margin-right: 10px;
                padding: 4px;
                border: 3px solid transparent;
            }
            .red-ui-popover-key {
                color: var(--red-ui-header-menu-color-disabled) !important;
                border-color: var(--red-ui-header-menu-color-disabled) !important;
            }
            &.active img {
                border: 3px solid var(--red-ui-header-menu-item-border-active);
            }

            span.red-ui-menu-label-container {
                width: 180px;
                vertical-align: top;
                display: inline-block;
                text-indent: 0px;
            }
            span.red-ui-menu-label {
                font-size: 14px;
                text-indent: 0px;
            }
            span.red-ui-menu-sublabel {
                color: var(--red-ui-header-menu-sublabel-color);
                font-size: 13px;
                display: block;
                text-indent: 0px;
            }
        }
        > li > a:hover,
        > li.open > a,
        > li > a:focus,
        > li:hover > a,
        > li:focus > a {
            background: var(--red-ui-header-menu-item-hover) !important;
        }
        li.red-ui-menu-divider {
            background: var(--red-ui-headerMenuItemDivider);
        }
        li.disabled a {
            color:  var(--red-ui-header-menu-color-disabled);
        }
        > li.disabled > a:hover,
        > li.disabled > a:focus {
            background: none !important;
        }
    }
    .red-ui-menu-dropdown-submenu>a:before {
        border-right-color: var(--red-ui-headerMenuCaret);
        margin-left: -25px !important;
    }

    /* Deploy menu customisations */
    ul#red-ui-header-button-deploy-options-submenu {
        width: 300px !important;
        li a {
            padding: 10px 30px;
            color: var(--red-ui-header-menu-heading-color);
            span.red-ui-menu-label {
                font-size: 16px;
                display: inline-block;
                text-indent: 0px;
            }
            > i.fa {
                display: none;
            }
        }
    }
    /* User menu customisations */
    #usermenu-item-username > .red-ui-menu-label {
        color: var(--red-ui-header-menu-heading-color);
    }
}


.red-ui-user-profile {
    background-color: var(--red-ui-header-background);
    border: 2px solid var(--red-ui-header-menu-color);
    border-radius: 30px;
    overflow: hidden;

    background-position: center center;
    background-repeat: no-repeat;
    background-size: contain;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    vertical-align: middle;
    width: 30px;
    height: 30px;
    font-size: 20px;

    &.red-ui-user-profile-color-1 {
        background-color: var(--red-ui-user-profile-colors-1);
    }
    &.red-ui-user-profile-color-2 {
        background-color: var(--red-ui-user-profile-colors-2);
    }
    &.red-ui-user-profile-color-3 {
        background-color: var(--red-ui-user-profile-colors-3);
    }
    &.red-ui-user-profile-color-4 {
        background-color: var(--red-ui-user-profile-colors-4);
    }
    &.red-ui-user-profile-color-5 {
        background-color: var(--red-ui-user-profile-colors-5);
    }
}


@media only screen and (max-width: 450px) {
    span.red-ui-header-logo > span {
        display: none;
    }
}
